import { http } from "../../utils";
export * from './article'
export const getChannels = () => {
    return async dispatch => {
        const data = await http.get('channels')
        dispatch({ type: 'article/setChannels', payload: data.channels })
    }
}
export const getArticles = (params) => {
    return async dispatch => {
        const data = await http.get('mp/articles', { params })
        dispatch({ type: "article/setArticles", payload: data })
    }
}
export const delArticle = (id) => {
    return async dispatch => {
        await http.delete(`mp/articles/${id}`)
    }
}
export const addArticle = (data, draft = false) => {
    return async dispatch => {
        await http.post(`mp/articles?draft=${false}`, data)
    }
}
export const editArticle = (data, draft = false) => {
    console.log(data,'data====26');
    return async dispatch => {
        await http.put(`mp/articles/${data.id}?draft=${draft}`, data)
    }
}
export const getArticle = id => {
    return async dispatch => {
        const data = await http.get('mp/articles/' + id)
        return data
    }
}